public class Result {
    public String question;
    public String [] possible_answers;
    public String [] oeResponses;
    public int q_type;
    public double[] percents;
    
    // constructors
    Result(String q, int type, String[] answers, double[] results){
        question = q;
        q_type = type;
        possible_answers = answers;
        percents = results;
    }
        
    Result(String q, int type, String[] responses){
        question = q;
        q_type = type;
        oeResponses = responses;
    }
    
    // method to get question content
    String getContent(){
        return question;
    }
    
    // method to get possible answers to question
    String [] getPossibleAns(){
        return possible_answers;
    }
    
    // method to get responses to open ended questions
    String [] getOEResponses(){
        return oeResponses;
    }
    
    // method to get question type  2 for multiple choice and 3 for open ended
    int getType(){
        return q_type;
    }
    
    // method to get the percentages of times each answer is given
    double[] getPercentages(){
        return percents;
    }
    
    // to String method to make results displayable
    public String toString(){
    	String str = question + "\n";
    	if(q_type == 2){
    		for(int i = 0; i< possible_answers.length; i++){
    			str = str + "     "+ possible_answers[i] + "     " + percents[i] + "\n";
    		}
    	}
    	if(q_type == 3){
    		for(int i = 0; i< oeResponses.length; i++){
    			str = str + "     " + oeResponses[i] + "\n";
    		}
    	
    	}
    	return str + "\n";
    }
    
    public static void main(String[] args){
		double[] d1 = new double[5];
		d1[0] = 10;
		d1[1] = 0;
		d1[2] = 10;
		d1[3] = 20;
		d1[4] = 60;
    	String[] strAr = {"ok", "good", "fair", "average"};
    	Result r = new Result("How r u", 2, strAr, d1);
    	
    	String[] rasdf2 = {"Remove","It","From","The","Required","Curriculum"};
    	Result r2 = new Result("How can this course be improved?", 3, rasdf2);

    	System.out.println(r.toString());
    	System.out.println(r2.toString());
    }
}

